package bar;

import java.security.MessageDigest;
import java.sql.Connection;
import java.sql.Statement;

import org.h2.jdbcx.JdbcDataSource;

public class DigestTest {

	public static void main(String[] args) throws Exception{
		MessageDigest md = MessageDigest.getInstance("SHA-256");
		md.update("test".getBytes());
		System.out.println(byteArrayToHex(md.digest()));
		System.out.println(byteArrayToHex(md.digest()));
		md.update("test".getBytes());
		md.update("salt".getBytes());
		System.out.println(byteArrayToHex(md.digest()));
		md.update("testsalt".getBytes());
		System.out.println(byteArrayToHex(md.digest()));
		
	}
	
	public static String byteArrayToHex(byte[] a) {
		   StringBuilder sb = new StringBuilder();
		   for(byte b: a)
		      sb.append(String.format("%02x", b&0xff));
		   return sb.toString();
		}

}
